package imper.main.listener;

import imper.engine.entity.Country;
import imper.engine.entity.Resources;
import imper.engine.entity.ResourcesType;
import imper.engine.util.ParameterManager;
import imper.graphic.ButtonListener;
import imper.graphic.event.ClickEvent;

public class AddTransportRealListener implements ButtonListener
{
	protected ResourcesType _ResourceType;

	public AddTransportRealListener( ResourcesType pResourceType )
	{
		this._ResourceType = pResourceType;
	}

	@Override
	public void click(ClickEvent pEvent)
	{
		Country country = ParameterManager.getInstance().getCountry();
		Resources resourceReal = country.getResourceTransportReal().getResources(_ResourceType.getId());
		Resources resourceCalc = country.getResourceTransportCalc().getResources(_ResourceType.getId());
		int newValue = resourceReal.getValue() + 1;
		if (newValue <= resourceCalc.getValue())
		{
			resourceReal.setValue(newValue);
		}
	}

}
